<%@page import="com.skeleton.utils.BaseConstants"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>注册</title>
	<link href="<%=request.getContextPath() %>/resource/css/ske-login.css" rel="stylesheet" type="text/css" />
	<script src="<%=request.getContextPath() %>/resource/js/jquery-1.8.2.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath() %>/resource/js/ske-common.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath() %>/resource/js/ske-constants.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath() %>/resource/js/ske-login.js" type="text/javascript" charset="utf-8"></script>
	<script src="<%=request.getContextPath() %>/resource/js/ske-encrypt.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">
		function regist() {
			var name = $('#loginname').val();
			var pass = $('#password').val();
			var pass2 = $('#password2').val();
			
			if(!isEmpty(name) && !isEmpty(pass) && pass==pass2 ) {
				$.ajax({
					url: "<%=request.getContextPath() %>/user/ajaxRegist",
					data: {
						loginname: name,
						password: encrypt(name, pass)
					},
					dataType: "JSON",
					type: "POST",
					success: function(res) {
						if(res.result == JS_AJAX_SUCCESS) {
							$('#msg').html("注册成功，请<a href="+rootPath+"'/login'>登录</a>");
						} else {
							$('#msg').html(res.msg);
						}
					}
				});
			} else {
				$('#msg').html("信息不正确");
			}
		}
	</script>
</head>
<body>
	<h1>注册</h1>
	<h2 style="color: red;" id="msg"></h2>
	登录名：<input type="text" id="loginname"/><br />
	密码：<input type="password" id="password"/><br />
	确认密码：<input type="password" id="password2"/><br />
	<input type="button" value="注册" onclick="regist()"/>
	<br />
	去<a href="<%=request.getContextPath() %>/login">登录</a>
</body>
</html>